package controler.controler;


import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Spinner;
import java.util.ArrayList;
import java.util.List;

import modele.DAO;

public class MainActivity extends ListActivity 
{
    /** Called when the activity is first created. */
    
    protected void onListItemClick(ListView l, View v, int position, long id){
        Intent inter = new Intent(this, MedActivity.class);
        inter.putExtra("leDep", l.getItemAtPosition(position).toString());
        startActivity(inter);
    }
    
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
         List<String> lesDeps = DAO.getLesDeps();
         ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,lesDeps);
        setListAdapter(adapter);
//ArrayAdapter<String> adapter = new ArrayAdapter<String> (this,
//					android.R.layout.simple_spinner_item, lesDeps);
//adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
//Spinner spinner = (Spinner) findViewById (R.id.spinnerDeps);
//spinner.setAdapter (adapter);
//
//
//spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
//    public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
//        
//       
//    }
//    public void onNothingSelected(AdapterView<?> parent) {
//    }
//});
 
       
//spinner.setOnItemSelectedListener(new OnItemSelectedListener(){
//    public void onItemSelected(View arg0){
//            List <String> lesMedsParDeps = DAO.getLesMedsParDep()
//        }
//})

//ArrayAdapter<String> adapter2 = new ArrayAdapter<String> (this,
//					android.R.layout.simple_spinner_item, lesMeds);
//adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
//Spinner spinner2 = (Spinner) findViewById (R.id.spinnerMeds);
//spinner2.setAdapter (adapter);
    }
    
}
